﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HeroDream
{
  public  class Equipment
    {
        protected string name;

        protected int fight;

        protected int price;

        public int Price => price;

        public string Name => name;

        public int Fight => fight;

        public Equipment(string name,int send)
        {
            this.name = name;
            Random random = new Random(DateTime.Now.Millisecond+ send);
            fight = random.Next(10, 100);
            price = random.Next(10, 100);
        }

        public Equipment(string name)
        {
            this.name = name;
            fight = 0;
            price = 0;
        }

        public void Output()
        {
            Console.WriteLine($"【装备{name}】 战斗力{fight} 价格{price}" );
        }

        public int GetFight()
        {
            return fight;
        }


        public void BeForging()
        {
            fight += 10;
        }

        /// <summary>
        /// 装备合并
        /// 采用运算符重载
        /// </summary>
        /// <param name="a"></param>
        /// <param name="b"></param>
        /// <returns></returns>
        public static Weapon operator +(Equipment a,Equipment b)
        {
            Weapon weapon = new Weapon($"[精]<{a.name}_{b.name}>");
            weapon.fight = a.fight + b.fight;
            weapon.price = (a.price + b.price) / 2;
            return weapon;
        }

    }
}
